package com.example.teacherservice.dto;

import com.example.teacherservice.entity.Comment;
import lombok.Data;
import java.time.LocalDateTime;

/**
 * 用户评论DTO（学生/教师通用）
 */
@Data
public class UserCommentDTO {
    private Long id;
    private String content;
    private LocalDateTime createTime;  // 改为LocalDateTime
    private Long questionId;
    private Boolean isStudent;
    private Boolean isAdopted;

    // 添加转换方法
    public static UserCommentDTO fromEntity(Comment comment) {
        UserCommentDTO dto = new UserCommentDTO();
        dto.setId(comment.getId());
        dto.setContent(comment.getContent());
        dto.setCreateTime(comment.getCreateTime());
        dto.setQuestionId(comment.getQuestionId());
        dto.setIsStudent(comment.getStudentId() != null);
        dto.setIsAdopted(comment.getHasAdopt() == 1);
        return dto;
    }
}